package com.whale.springsession.config;

import com.whale.springsession.service.MyAccessDeniedHandler;
import com.whale.springsession.service.MyAuthenticationEntryPoint;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;

@Configuration
public class DingProSecurityAutoConfiguration extends WebSecurityConfigurerAdapter implements Ordered {

    @Override
    @SuppressWarnings("PMD.SignatureDeclareThrowsException")
    public void configure(HttpSecurity http) throws Exception {
        http.requestMatchers()
        .and().authorizeRequests()
        .anyRequest().authenticated()
        .and().exceptionHandling().authenticationEntryPoint(new MyAuthenticationEntryPoint())
        .accessDeniedHandler(new MyAccessDeniedHandler())
        ;
    }

    @Override
    public int getOrder() {
        return 102;
    }



}
